--*************ANIMATION SUITE****************--
--**************Property of Hxrmn*****************--
--*************Hxrmn@comcast.net*****************--
--DO NOT RE-DISTRIBUTE WITHOUT HXRMN'S CONSENT--
--********************************************--

AS_PLAY_PINGPONG = 1
AS_PLAY_LOOP = 2
AS_PLAY_ONCE = 3

AS_MESSAGE_CHAT = 3

AS_STATUS_IDLE = 0
AS_STATUS_RECORD = 1
AS_STATUS_PLAY = 2

include( 'EntityUtilities.lua' )
include( 'AnimatorInstance.lua' )
include( 'Track.lua' )
include( 'KeyFrame.lua' )
include( 'Property.lua' )
include( 'Controls.lua' )
if(CLIENT) then
	include( 'vgui/init.lua' )
end
AS_Animators = {}

function AS_Error( txt )
	Msg("AnimationSuite-ERROR: " .. txt .. "\n")
end

function AS_Msg( txt,animator,t )
	if(SERVER) then
		animator:GetPlayer():PrintMessage(t,txt)
		Msg("SV: " .. txt .. "\n")
	else
		--animator:GetPlayer():PrintMessage(t,"CL: " .. txt)
		LocalPlayer():ConCommand("AS_MsgX " .. txt .. " " .. t .. "\n")
		Msg("CL: " .. txt .. "\n")
	end
end

if(SERVER) then
	function AS_Msg2( p,c,a )
		p:PrintMessage(tonumber(a[2]),a[1])
		Msg("SV: " .. a[1] .. " " .. a[2] .. "\n")
	end
	concommand.Add("AS_MsgX",AS_Msg2)
end

function AS_GetAnimator(p)
	if(CLIENT) then return LocalPlayer():GetTable().animatorMeta end
	if(p != nil) then
		return p:GetTable().animatorMeta
	end
end

function AS_Think()
	for k,v in pairs(AS_Animators) do
		v:Think()
	end
end
hook.Add("Think","AS_THINK",AS_Think)

function AS_InitPlayer(p)
	local animator = Animator:Employ(p)
	table.insert(AS_Animators, animator)
end

function AS_EndPlayer(p)
	AS_GetAnimator(p):Dismiss()
end